#ifndef __GLF_COMPILER_H_INCLUDED__
#define __GLF_COMPILER_H_INCLUDED__

namespace glf {
template <bool x>
struct STATIC_ASSERTION_FAILURE;

template <>
struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };

template<int x>
struct static_assert_test {};

} //namespace glf

#define GLF_COMPILER_ASSERT(x) typedef glf::static_assert_test<sizeof(glf::STATIC_ASSERTION_FAILURE< (bool)( x ) >)> GLF_JOIN(static_assert_typedef_, __COUNTER__)


namespace glf {

template<int a, int b>
struct TestLt {
	char buffer[a < b ? 1:-1];
};

template<int a, int b>
struct TestLe {
	char buffer[a <= b ? 1:-1];
};

template<int a, int b>
struct TestEq {
	char buffer[a == b ? 1 : -1];
};

} //namespace glf

#define GLF_STATIC_ASSERT_LT(a, b) glf::TestLt<a,b>()
#define GLF_STATIC_ASSERT_LE(a, b) glf::TestLe<a,b>()
#define GLF_STATIC_ASSERT_EQ(a, b) glf::TestEq<a,b>()
#define GLF_STATIC_ASSERT(c)       glf::TestEq<c,true>()

#if defined(__CWCC__) || defined(__MWERKS__)

	#define GLF_COMPILER mwerks
	#define GLF_COMPILER_MWERKS 1
#elif defined(SDK_CW) && SDK_CW

	#define GLF_COMPILER mwerks
	#define GLF_COMPILER_MWERKS 1

#elif defined(_MSC_VER)

	#define GLF_COMPILER msvc
	#define GLF_COMPILER_MSVC 1

#elif defined(NN_COMPILER_RVCT) || (defined(__arm__) && defined(__ARMCC_VERSION))

	#define GLF_COMPILER rvct
	#define GLF_COMPILER_RVCT 1

#elif defined(__SNC__)

	#define GLF_COMPILER snc
	#define GLF_COMPILER_SNC 1

#elif defined(GCC) || defined(__GCC__)

	#define GLF_COMPILER gcc
	#define GLF_COMPILER_GCC 1

#elif defined(PLATFORM_JIL)

	#define GLF_COMPILER gcc
	#define GLF_COMPILER_GCC 1

#else

	#define GLF_COMPILER gcc
	#define GLF_COMPILER_GCC 1

#endif

#define GLF_COMPILER_HEADER(path)				GLF_COMPILER_HEADER1(path, GLF_COMPILER)
#define GLF_COMPILER_HEADER1(path, compiler)	GLF_COMPILER_HEADER2(path, compiler)
#define GLF_COMPILER_HEADER2(path, compiler)	GLF_COMPILER_HEADER3(path, compiler)
#define GLF_COMPILER_HEADER3(path, compiler)	<path##_##compiler##_.h>

#if 0 //MACOSX
	#include <glf/config/compiler_macos_.h>
#elif defined(SN_TARGET_PSP2) // Compilation fix with distributed build
	#include <glf/config/compiler_snc_.h>
#else
	#include GLF_COMPILER_HEADER(glf/config/compiler)
#endif


#endif
